// app.js
App({
  globalData: {//全局变量
    // userInfo:getUserInfo
    },
    onLaunch: function () {
      if (!wx.cloud) {
        console.error('请使用 2.2.3 或以上的基础库以使用云能力');
      } else {
        wx.cloud.init({
           env: 'cloud1-6gb2kgs74493b1a7',
          traceUser: true,
        });
      }
      // 获取用户信息
      wx.getSetting({
        success: res => {
          if (res.authSetting['scope.userInfo']) {
            // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
            wx.getUserProfile({
              success: res => {
                this.globalData.userInfo = res.userInfo
                if (this.userInfoReadyCallback) {
                  this.userInfoReadyCallback(res)
                }
              }
            })
          }
        }
      })
      let menuButtonObject = wx.getMenuButtonBoundingClientRect();
    console.log("小程序胶囊信息",menuButtonObject)
    wx.getSystemInfo({
      success: res => {
        let statusBarHeight = res.statusBarHeight,
          navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
          navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;//导航高度
        this.globalData.navHeight = navHeight;
        this.globalData.navTop = navTop;
        this.globalData.windowHeight = res.windowHeight;
        this.globalData.menuButtonObject = menuButtonObject;
        console.log("navHeight",navHeight);
      },
      fail(err) {
        console.log(err);
      }
    })
    },
    getSystemInfo: function () {
      var that = this;
      wx.getSystemInfo({
        success: function (res) {
          that.globalData.systemInfo = res;
          console.log(res);
        }
      });
     
    },
    globalData: {
      systemInfo: null,//客户端设备信息
      userInfo: null,
      tabBar: {
        "backgroundColor": "#ffffff",
        "color": "#979795",
        "selectedColor": "#1c1c1b",
        "list": [
          {
            "pagePath": "/pages/index/index",
            "iconPath": "/images/idnex.png",
            "selectedIconPath": "/images/indexa.png",
            "text": "首页"
          },
          {
            "pagePath": "/pages/mine/mine",
            "iconPath": "/images/mine.png",
            "selectedIconPath": "/images/minea.png",
            "text": "我的"
          },
        ]
      }
    }
});
